﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;

public partial class TestD : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        using (SqlConnection con = DBHelper.GetSqlConnection())
        {
            con.Open();
            SqlTransaction tran = con.BeginTransaction();
            try
            {
                test(con, tran);
                tran.Commit();
            }
            catch (SqlException ex1)
            {
                Logger.WriteLog("执行resource事务数据库异常", ex1);
                try
                {
                    tran.Rollback();
                }
                catch (Exception ex2)
                {
                    Logger.WriteLog("执行resource事务回滚异常", ex2);
                }
            }
            catch (Exception ex1)
            {
                Logger.WriteLog("执行resource事务异常", ex1);
                try
                {
                    tran.Rollback();
                }
                catch (Exception ex2)
                {
                    Logger.WriteLog("执行resource事务回滚异常", ex2);
                }
            }
            finally
            {
                con.Close();
            }
        }
    }


    public void test(SqlConnection connection, SqlTransaction transaction)
    {
        SqlConnection conn = connection;
        SqlTransaction tran = transaction;
        //DBHelper.ExecuteNonQuery("")
    }
}